home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / ASMLIB30.ARJ / SYSTEM.DOC < prev    next >
Text File  |  1992-06-13  |  16KB  |  538 lines

  1.  
  2. *****************************  SYSTEM  *************************************
  3.  
  4. ASMLIB system subroutines Copyright (C) 1991, 1992 Douglas Herr
  5. all rights reserved
  6.  
  7.  
  8. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  9.  
  10. BREAKTRAP:   initialize Ctrl+Break trap
  11. BREAKRELEASE:restore previous Ctrl+Break handler
  12. Source:      break.asm
  13.  
  14. BREAKFLAG:   public byte in DGROUP, indicating Ctrl+Break key press
  15. Source:      asmflags.asm
  16.  
  17. Call with:   no parameters
  18.              BreakTrap uses well-behaved methods to trap Ctrl+Break,
  19.              Ctrl+C and Ctrl-Alt-Del key sequences.  When one of these
  20.              key combinations is pressed, ASMLIB's break trap sets the
  21.              public flag "breakflag" in the data area.  BreakRelease
  22.              de-activates ASMLIB's break trap, restoring the previous
  23.              Ctrl+Break handler.  BreakFlag = 0 until a monitored key
  24.              combination is pressed, at which time breakflag is set
  25.              equal to 1.  If you use BreakTrap, you MUST call BreakRelease
  26.              before the end of your program, or you will find yourself
  27.              reaching for the Big Red Switch.  See STARTUP.ASM.
  28. Returns:     nothing
  29. Uses:        nothing
  30. Example:     see STARTUP.ASM
  31.  
  32.  
  33.  
  34. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  35.  
  36. DOSALLOC:    allocate memory block from unused DOS memory
  37. Source:      dosalloc.asm
  38.  
  39. Call with:   DX:AX = number of bytes to allocate
  40.              DOSAlloc uses DOS function 48h to allocate memory from free
  41.              DOS memory.  See STARTUP.ASM and subroutine ENDPROG.
  42. Returns:     if CF = 0, AX = segment address of start of memory block
  43.                              offset of start of memory block = 0
  44.              if CF = 1, insufficient DOS memory space is available.
  45. Uses:        AX, CF; all other flags and registers are saved
  46. Example:
  47.  
  48. .model huge
  49.  
  50. extrn    bitblockbytes:proc, dosalloc:proc
  51.  
  52. .code
  53. ; this example uses bitblockbytes to calculate the memory required
  54. ; to save a bit block on a graphics screen
  55.          .
  56.          .
  57.          .
  58.          lea   bx,corners      ; point to bit block corner coordinates
  59.          call  bitblockbytes   ; returns DX:AX = number of bytes required
  60.          call  dosalloc
  61.          jc    no_memory       ; do some error handling stuff
  62.  
  63.  
  64.  
  65. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  66.  
  67. ENDPROG:     determines program's code, static data and stack size
  68.              this is handy for dynamic memory allocation, or for TSR work
  69. Source:      endprog.asm
  70.  
  71. Call with:   no parameters
  72. Returns:     AX = segment address of end of program.  See STARTUP.ASM.
  73.              ENDPROG defines ZSEG as the last segment in the program.
  74.              If you add any object modules to ASMLIB.LIB, be certain any
  75.              segments in the added modules are defined before LINK
  76.              encounters ENDPROG.  Be sure to review the .MAP file after
  77.              linking.
  78. Uses:        AX
  79. Example:     see STARTUP.ASM
  80.  
  81.  
  82. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  83.  
  84. EXENAME:     determine the full path and filename of the executing program
  85. Source:      exename.asm (strlen.asm)
  86.  
  87. Call with:   ES = PSP segment (see STARTUP.ASM)
  88. Returns:     ES:[BX] pointing to the the name of the executing program,
  89.              including drive and full path, CX = length of the filename.
  90.              The filename returned is an ASCIIZ string, and may be mixed
  91.              upper- and lower-case characters.
  92. Uses:        ES, BX, CX; all other registers and flags are saved.
  93. Example:
  94.  
  95. include asm.inc
  96.  
  97. extrn   exename:proc
  98.  
  99. .data
  100. extrn   pspseg:word
  101.  
  102. .code
  103. ; program fragment assumes DS:@data
  104.         .
  105.         .
  106.         .
  107.         mov   es,pspseg
  108.         call  exename         ; string returned at ES:[BX] can be
  109.                               ; copied to heap with STRNDUP
  110.  
  111.  
  112.  
  113. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  114.  
  115. FINDMONO:    detects a monochrome-compatible video card
  116.              this is handy in 2-monitor systems.
  117. Source:      findmono.asm (a$herc.asm, isega.asm, find6845.asm)
  118.  
  119. Parameters:  none
  120. Returns:     if CF = 1, no monochrome monitor
  121.              if CF = 0, AX = monitor code
  122.               0 = MDA
  123.               0101h = EGA monochrome
  124.               0301h = VGA monochrome
  125.               128 = Hercules or clone
  126.               144 = Hercules Graphics Card plus
  127.               208 = Hercules InColor
  128. Uses:        AX, CF
  129. Supports:    MDA, EGA & VGA MONO, HGC, HGC+, InColor
  130. Example:     call  findmono
  131.              jc    no_monochrome
  132.  
  133.  
  134.  
  135. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  136.  
  137. FLOPPIES:    determine the number of floppy disk drives intalled
  138. Source:      floppies.asm
  139.  
  140. Call with:   no parameters
  141. Returns:     AX = number of floppy drives
  142. Uses:        AX; all other registers and flags are saved
  143. Example:
  144.  
  145. .model medium
  146.  
  147. public  myproc
  148. extrn   floppies:proc
  149.  
  150. .code
  151. myproc  proc
  152.         .
  153.         call   floppies
  154.  
  155.  
  156.  
  157. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  158.  
  159. FLOPPYTYPE:  determine the number of floppy disk drives intalled
  160. Source:      floptype.asm
  161.  
  162. Call with:   DL = drive number (0 = drive A:)
  163. Returns:     AX = floppy drive type
  164.               0 = invalid drive number
  165.               1 = 360k
  166.               2 = 1.2M
  167.               3 = 720k
  168.               4 = 1.44M
  169. Uses:        AX, flags
  170. Example:
  171.  
  172. .model medium
  173.  
  174. public  myproc
  175. extrn   floppytype:proc
  176.  
  177. .data
  178. drive_number   db 0
  179.  
  180. .code
  181. myproc  proc
  182.         .
  183.         mov    dl,drive_number
  184.         call   floppytype
  185.         or     ax,ax
  186.         jz     bad_drive_number
  187.  
  188. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  189.  
  190. GETCPU:      detects cpu type
  191. Source:      getcpu.asm
  192.  
  193. Call with:   no parameters
  194. Returns:     AX = 0 if 8086/8088
  195.              AX = 1 if 80186/80188
  196.              AX = 2 if 80286
  197.              AX = 3 if 386 (SX or DX)
  198.              AX = 4 if 486 (SX or DX)
  199. Uses:        AX
  200. Example:     call   getcpu
  201.  
  202.  
  203.  
  204. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  205.  
  206. GETCRT:      determines active monitor type
  207. Source:      getcrt.asm (a$herc.asm, isevga.asm)
  208.  
  209. Call with:   no parameters
  210. Returns:     AX = code for active video system
  211.              CGA = -1
  212.              MDA = 0
  213.              EGA mono = 0100h
  214.              VGA mono = 0300h
  215.              EGA color = 1
  216.              MCGA = 2
  217.              VGA color = 3
  218.              HGC = 128
  219.              HGC+ = 144
  220.              InColor = 208
  221.              Note: GetCRT may be re-assembled with the /DNOHERC switch
  222.              to eliminate code which detects Hercules equipment
  223. Uses:        AX
  224. Supports:    CGA, MCGA, MDA, HGC, HGC+, InColor, EGA, VGA
  225. Example:     call    getcrt
  226.  
  227.  
  228.  
  229. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  230.  
  231. HALLOC:      allocates memory from near heap
  232. Source:      heap.asm
  233.  
  234. Call with:   AX = bytes requested; assumes DS:@data
  235.              heap must be initialized with hinit
  236. Returns:     if space available:
  237.              BX = near pointer for allocated data
  238.              if space not available:
  239.              CF = 1
  240. Uses:        AX, BX, flags
  241. Example:     mov   ax,bytes
  242.              call  halloc
  243.              jc    no_memory       ; check to see if there was enough space
  244.  
  245.  
  246. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  247.  
  248. HFREE:       releases heap memory previously allocated
  249. Source:      heap.asm
  250.  
  251. Call with:   BX = near pointer to memory block; assumes DS:@data
  252. Returns:     nothing
  253. Uses:        AX, BX, flags
  254. Example:     mov   bx,pointer
  255.              call  hfree
  256.  
  257.  
  258.  
  259. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  260.  
  261. HINIT:       initializes heap manager
  262. Source:      heap.asm
  263.  
  264. Call with:   AX = number of bytes to be managed by heap manager
  265.              2 <=bytes<= 32767
  266.              BX = near pointer to memory block to be managed
  267.              assumes  DS:@data
  268. Returns:     CF = 0 if ok, CF = 1 if bad parameter (bytes too
  269.              small or too large)
  270. Uses:        flags
  271. Example:
  272.  
  273. .data
  274. heap   db  32767 dup(0)
  275.  
  276. .code
  277.        mov    ax,@data
  278.        mov    ds,ax
  279.        assume ds:@data
  280.        mov    ax,32767
  281.        lea    bx,heap
  282.        call   hinit
  283.  
  284.  
  285. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  286.  
  287. HMAX:        determines largest free block in asmlib's near heap
  288. Source:      heap.asm
  289.  
  290. Call with:   no parameters
  291. Returns:     AX = block size in bytes
  292.              AX = -1 if the heap has not been initialized
  293. Uses:        AX
  294. Example:     call   hmax
  295.  
  296.  
  297.  
  298. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  299.  
  300. HREALLOC:    re-sizes a block of memory in the near heap
  301. Source:      heap.asm
  302.  
  303. Call with:   BX = original pointer to memory block
  304.              AX = new byte size
  305. Returns:     if successful, CF = 0, BX = new block pointer
  306.              if not successful, CF = 1
  307. Uses:        BX, flags
  308. Example:     mov    bx,pointer
  309.              mov    ax,newsize
  310.              call   hrealloc
  311.  
  312.  
  313. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  314.  
  315. ISANSI:      determines if ANSI or compatible is loaded and active
  316. Source:      isansi.asm
  317.  
  318. Parameters:  none
  319. Returns:     CF = 1 if no ANSI device driver loaded and active
  320.              CF = 0 if ANSI loaded and active
  321. Uses:        CF
  322. Example:     call   isansi         ; let's see if ansi.sys is loaded
  323.              jc     no_ansi        ; jump if not
  324.  
  325.  
  326.  
  327. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  328.  
  329. ISEVGA:      determines if an EGA or VGA is installed
  330. Source:      isevga.asm
  331.  
  332. Call with:   no parameters
  333. Returns:     if CF = 1, no EGA or VGA
  334.              if CF = 0
  335.                DX = video memory in kbytes
  336.                AL = monitor type
  337.                 AL = -1 if monitor is CGA
  338.                 AL = 0 if monitor is monochrome
  339.                 AL = 1 if monitor is EGA or better
  340.  
  341.                AH = EGA/VGA flag
  342.                 AH = 1 if EGA
  343.                 AH = 3 if VGA
  344.  
  345. Uses:        AX, DX, CF
  346. Example:     call   isevga
  347.              jc     no_evga
  348.  
  349.  
  350. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  351.  
  352. ISHERC:      determines if a Hercules card or compatible is installed
  353.              and if so, determines if it is the active video system.
  354. Source:      isherc.asm (a$herc.asm)
  355.  
  356. Call with:   no parameters
  357. Returns:     if CF = 1, no Hercules or compatible installed
  358.              if CF = 0, AX = Hercules model
  359.              128 = Hercules Graphics Card or compatible; active
  360.              144 = Hercules Graphics Card Plus; active
  361.              208 = Hercules InColor card; active
  362.              -128 = Hercules Graphics Card or compatible; not active
  363.              -144 = Hercules Graphics Card Plus; not active
  364.              -208 = Hercules InColor card; not active
  365. Uses:        AX, CF; all other flags and registers are saved
  366. Example:     call  isherc
  367.              jc    no_herc
  368.  
  369.  
  370.  
  371. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  372.  
  373. ISMOUSE:     determines if a mouse is installed
  374. Source:      ismouse.asm (asmflags.asm)
  375.  
  376. Parameters:  none
  377. Returns:     AX = number of mouse buttons
  378.              AX = 0 if no mouse or mouse driver installed
  379. Uses:        AX
  380. Example:
  381.  
  382. include  asm.inc
  383.  
  384. .code
  385.        .
  386.        .
  387.        .
  388.        call    ismouse
  389.        or      ax,ax
  390.        jz      no_mouse
  391.  
  392.  
  393.  
  394. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  395.  
  396. ISSEVGA:     determines if a Super EGA or Super VGA is installed
  397. Source:      issevga.asm
  398.  
  399. Parameters:  none
  400. Returns:     if CF = 1, no Super EGA or Super VGA recognized by ASMLIB
  401.  
  402.              if CF = 0
  403.  
  404.               if AH = 1: (Super EGA)
  405.                AL = 1 if Paradise EGA 480
  406.                AL = 2 if Everex EGA
  407.  
  408.               if AH = 3: (Super VGA)
  409.                AL = 1 if Paradise VGA
  410.                AL = 3 if Tseng VGA chipset
  411.                AL = 4 if Oak VGA
  412.                AL = 5 if Western Digital VGA chipset
  413.  
  414.              See also IsEVGA
  415. Uses:        AX, CF
  416. Example:     call   issevga
  417.              jc     no_superevga
  418.  
  419.  
  420.  
  421. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  422.  
  423. MATHCHIP:    determines if 80x87 math coprocessor is installed
  424. Source:      mathchip.asm
  425.  
  426. Parameters:  none
  427. Returns:     AX = code for 80x87 model
  428.              0 = not installed
  429.              1 = 8087
  430.              2 = 287
  431.              3 = 387 (DX or SX)
  432.              4 = 487 (486DX or 487SX)
  433.              If the coprocessor is present, it is initilaized by MathChip.
  434. Uses:        AX, all 80x87 registers
  435. Example:     call  mathchip
  436.  
  437.  
  438. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  439.  
  440. MOUSEINIT:   initializes mouse driver if mouse present
  441. Source:      mouseini.asm
  442.  
  443. MOUSEFLAG:   public byte in DGROUP indicating mouse buttons
  444. Source:      asmflags.asm
  445.  
  446. Parameters:  assumes DS:@data
  447. Returns:     if mouse installed, ZF = 0 and AX = number of mouse buttons
  448.              also updates mouseflag
  449.              if no mouse, ZF = 1 and AX = 0
  450. Uses:        AX, flags
  451. Example:
  452.  
  453. include asm.inc
  454.  
  455. extrn   mouseinit:proc
  456.  
  457. .code
  458. ; program fragment assumes DS:@data
  459.         .
  460.         .
  461.         .
  462.         call    mouseinit
  463.         jz      no_mouse
  464.  
  465.  
  466. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  467.  
  468. SYSTEM:      execute a second copy of COMMAND.COM;  optionally runs another
  469.              program.
  470. Source:      system.asm (strlen.asm)
  471.  
  472. Parameters:  ES = PSP segment
  473.              DS:[BX] points to command tail
  474.              if DS:[BX] points to a nul byte, control is transfered
  475.              to the second copy of COMMAND.COM and you get a DOS prompt.
  476.              control is passed back to the calling program when EXIT is
  477.              entered at the DOS prompt.
  478.  
  479.              if DS:[BX] points to an ASCIIZ string with the name of a
  480.              program (and optional command line parameters), the program
  481.              will be executed, and control will pass back to the calling
  482.              program at the termination of the second program.
  483. Returns:     nothing
  484. Uses:        AX
  485. Example:
  486.  
  487. include asm.inc
  488.  
  489. ; I want to go to DOS temporarily to format a 720k disk
  490. extrn   system:proc
  491.  
  492. .data
  493. ; PSP segment is saved here by my startup code
  494. pspseg  dw ?
  495. cmdtail db 'format a: /n:9 /t:80',0
  496.  
  497. .code
  498. ; program fragment assumes DS:@data
  499.         .
  500.         .
  501.         lea     bx,cmdtail    ; DS:[BX] points to command tail
  502.         mov     es,pspseg
  503.         call    system
  504.  
  505.  
  506. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  507.  
  508. USE32K:      limit Hercules equipment to 32k memory (128k on InColor)
  509. USE64K:      allow full 64k on HGC and HGC+ (256k on InColor)
  510. Source:      a$herc.asm
  511.  
  512. Requires Hercules or compatible
  513.  
  514. Call with:   no parameters
  515.              Use32k is equivalent to the Hercules "half" configuration
  516.              Use64k is equivalent to the Hercules "full" configuration
  517.              ASMLIB's default is "half".  Use this configuration if you
  518.              have a 2-monitor system, unless you are using the Hercules
  519.              CGA card. 
  520. Returns:     nothing
  521. Uses:        nothing
  522. Example:     ; in this example I'm determining if a Hercules is installed
  523.              ; and setting the configuration to "full"
  524. extrn  IsHerc:proc
  525. extrn  Use64k:proc
  526. .code
  527.        .
  528.        .
  529.        .
  530.        call  IsHerc
  531.        jc    no_herc
  532.        or    ax,ax
  533.        js    use_only_half   ; use_only_half if HGC is not default monitor
  534.        call  use64k          ; else use all Hercules memory
  535. use_only_half:
  536.  
  537.  
  538.